/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.controlador;

import com.modelo.UsuarioP;
import java.math.BigDecimal;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Juan Pablo
 */
public class EmailController {
    
    EntityManager em;
    EntityManagerFactory emf;
    
    public EmailController(){
        emf= Persistence.createEntityManagerFactory("pwPU");
        em=emf.createEntityManager();
    }    
    
    public String darEmail(String idUsuario){
        
                
        int num=Integer.parseInt(idUsuario);
        
        BigDecimal s=new BigDecimal(num);
        
        UsuarioP encontrado=em.find(UsuarioP.class, s);
        
        return encontrado.getCorreoElectronico();
    }
}
